package com.uenpay.im.ui.old.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.qyx.android.message.type.MsgStatusType;
import com.uenpay.im.IMApplication;
import com.uenpay.im.R;
import com.uenpay.util.app.ActivityStack;

/**
 * 其他设备登录提示框
 *
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class SignInOnOtherDeviceDialog extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.alret_dialog_view);
        TextView message = (TextView) findViewById(R.id.message);
        int type = getIntent().getIntExtra("type", 0);
        if (type != MsgStatusType.SIGN_IN_OTHER_DEVICE) {
            message.setText(getResources().getString(R.string.other_device));
        }
        findViewById(R.id.back_to_sign_in).setOnClickListener(
                new OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        exitApp();
                    }
                });
    }

    @Override
    public void onBackPressed() {
        exitApp();
        super.onBackPressed();
    }

    private void exitApp() {
        IMApplication.getInstance().ClearAllActivity();
        ActivityStack.getInstance().popAll();
        ARouter.getInstance().build("/main/login").navigation(this);
        finish();
    }
}